/*
 * @(#) ConfigServiceImpl.java 2011-10-2
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.system.business.service.impl;

import java.util.Date;

import cn.strong.gweva.common.business.entity.Environment;
import cn.strong.gweva.common.business.entity.db.JxkhConfigEntity;
import cn.strong.gweva.common.business.service.impl.AbstractServiceImpl;
import cn.strong.gweva.common.util.Constants;
import cn.strong.gweva.common.util.Constants4Method;
import cn.strong.gweva.system.business.service.ConfigService;

/**
 * 系统配置业务处理。
 * 
 * @author lilanfei
 * @version 1.0
 * @since 2011-10-2
 */
public class ConfigServiceImpl extends AbstractServiceImpl implements ConfigService
{
	/**
	 * 检索系统配置。
	 * 
	 * @return
	 * @throws Exception
	 */
	public JxkhConfigEntity searchConfig() throws Exception
	{
		return (JxkhConfigEntity)this.getCommonDao().searchObj(Constants4Method.SYSTEM_CONFIG_SEARCH_CONFIG, null);
	}
	
	/**
	 * 更新系统配置。
	 * 
	 * @param configEntity 系统配置
	 * @return
	 * @throws Exception
	 */
	public int updateConfig(JxkhConfigEntity configEntity) throws Exception
	{
		int cnt = 0;
		configEntity.setUpdateTime(new Date());
		if (configEntity.getConfigId() != null)
		{
			cnt = this.getCommonDao().update(Constants4Method.SYSTEM_CONFIG_UPDATE_CONFIG, configEntity);
		}
		else
		{
			configEntity.setDelFlag(Constants.DEL_FLAG_NO);
			this.getCommonDao().insert(Constants4Method.SYSTEM_CONFIG_INSERT_CONFIG, configEntity);
			cnt = 1;
		}
		Environment.refreshConfig(configEntity);
		return cnt;
	}
}
